package com.xuzimian.globaldemo.common;

import static org.apache.commons.lang3.StringUtils.isNotBlank;

public class TempDemo {

    public static void main(String[] args) {

        System.out.println(getPath("/", "/"));
        System.out.println(getPath("/", ""));
        System.out.println(getPath("", "/"));

        System.out.println(getPath("items", "getitem"));
        System.out.println(getPath("/items", "/getiem"));
        System.out.println(getPath("/items", "getitem"));
        System.out.println(getPath("items", "/getitem"));
    }

    private static String getPath(String parentPath, String childPath) {
        parentPath = isNotBlank(parentPath) && !parentPath.startsWith("/") ? ("/" + parentPath) : parentPath;
        childPath = isNotBlank(childPath) && !childPath.startsWith("/") ? ("/" + childPath) : childPath;
        return isNotBlank(parentPath) ? parentPath + childPath : childPath;
    }
}
